package com.sztx.pay.center.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sztx.pay.center.core.service.TreadQueryService;
import com.sztx.pay.center.dataaccess.dao.mysql.OrderB2cMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.mysql.OrderMappingMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.mysql.OrderRechargeMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.mysql.OrderRefundMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.mysql.OrderTransferMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.mysql.OrderWithdrawMysqlDAO;
import com.sztx.pay.center.dataaccess.dao.mysql.PayFlowMysqlDAO;
import com.sztx.pay.center.dataaccess.domain.OrderB2cDO;
import com.sztx.pay.center.dataaccess.domain.OrderMappingDO;
import com.sztx.pay.center.dataaccess.domain.OrderRechargeDO;
import com.sztx.pay.center.dataaccess.domain.OrderRefundDO;
import com.sztx.pay.center.dataaccess.domain.OrderTransferDO;
import com.sztx.pay.center.dataaccess.domain.OrderWithdrawDO;
import com.sztx.pay.center.dataaccess.domain.PayFlowDO;
import com.sztx.pay.center.dataaccess.entity.QueryOrder;
import com.sztx.se.core.service.impl.BaseServiceImpl;
import com.sztx.se.dataaccess.mysql.config.PageQuery;

@Service
public class TreadQueryServiceImpl extends BaseServiceImpl implements TreadQueryService{
	
	@Autowired
	private OrderB2cMysqlDAO orderB2cMysqlDAO;
	
	@Autowired
	private OrderRechargeMysqlDAO orderRechargeMysqlDAO;
	
	@Autowired
	private OrderRefundMysqlDAO orderRefundMysqlDAO;
	
	@Autowired
	private OrderTransferMysqlDAO orderTransferMysqlDAO;
	
	@Autowired
	private OrderWithdrawMysqlDAO orderWithdrawMysqlDAO;

	@Autowired
	private OrderMappingMysqlDAO orderMappingMysqlDAO;
	
	@Autowired
	private PayFlowMysqlDAO payFlowMysqlDAO;
	

	@Override
	public List<OrderB2cDO> B2CQuery(QueryOrder query, PageQuery pageQuery) {
		
		return orderB2cMysqlDAO.findQuery(query, pageQuery);
	}

	@Override
	public Integer B2CTotalCount(QueryOrder query) {
		
		return orderB2cMysqlDAO.totalCount(query);
	}

	@Override
	public List<OrderRechargeDO> rechargeQuery(QueryOrder query, PageQuery pageQuery) {
		
		return orderRechargeMysqlDAO.findQuery(query, pageQuery);
	}

	@Override
	public Integer rechargeTotalCount(QueryOrder query) {
		
		return orderRechargeMysqlDAO.totalCount(query);
	}

	@Override
	public List<OrderRefundDO> refundQuery(QueryOrder query, PageQuery pageQuery) {
		
		return orderRefundMysqlDAO.findRefund(query, pageQuery);
	}

	@Override
	public Integer refundTotalCount(QueryOrder query) {
		
		return orderRefundMysqlDAO.totalCount(query);
	}

	@Override
	public List<OrderTransferDO> transferQuery(QueryOrder query, PageQuery pageQuery) {
		
		return orderTransferMysqlDAO.findQuery(query, pageQuery);
	}

	@Override
	public Integer transferTotalCount(QueryOrder query) {
		return orderTransferMysqlDAO.totalCount(query);
	}

	@Override
	public List<OrderWithdrawDO> withdrawQuery(QueryOrder query, PageQuery pageQuery) {
		
		return orderWithdrawMysqlDAO.findQuery(query, pageQuery);
	}

	@Override
	public Integer withdrawTotalCount(QueryOrder query) {
		
		return orderWithdrawMysqlDAO.totalCount(query);
	}

	@Override
	public List<OrderMappingDO> orderMappingQuery(QueryOrder query, PageQuery pageQuery) {
		OrderMappingDO orderMappingDO = new OrderMappingDO();
		orderMappingDO.setTradeOrderId(query.getTradeOrderId());
		
		return orderMappingMysqlDAO.findOrderMapping(orderMappingDO, pageQuery);
	}

	@Override
	public Integer orderMappingTotalCount(QueryOrder query) {
		OrderMappingDO orderMappingDO = new OrderMappingDO();
		orderMappingDO.setTradeOrderId(query.getTradeOrderId());

		return orderMappingMysqlDAO.totalCount(orderMappingDO);
	}

	@Override
	public List<PayFlowDO> payFlowQuery(String originOrderId, List<String> tradeOrderIds, PageQuery pageQuery) {

		return payFlowMysqlDAO.findByTradeOrderIds(originOrderId, tradeOrderIds, pageQuery);
	}

	@Override
	public Integer payFlowCount(String originOrderId, List<String> tradeOrderIds) {
		
		return payFlowMysqlDAO.countByTradeOrderIds(originOrderId, tradeOrderIds);
	}
	
	
}
